		TITLE	ZERO - Copyright (c) SLR Systems 1994

		INCLUDE	MACROS


		PUBLIC	FINAL_HIGH_PARA,ZERO_EAX_FINAL_HIGH_WATER,ZERO_EAX_EDX_FINAL


		.DATA

		EXTERNDEF	TEMP_RECORD:BYTE,EXEPACK_STRUCTURE:BYTE

		EXTERNDEF	FINAL_HIGH_WATER:DWORD,ZERO_BYTES:DWORD


		.CODE	PASS2_TEXT

		EXTERNDEF	MOVE_EAX_TO_EDX_FINAL:PROC,STORE_EAXECX_EDX_SEQ:PROC


FINAL_HIGH_PARA PROC
		;
		;
		;
		XOR	EAX,EAX
		MOV	ECX,FINAL_HIGH_WATER

		SUB	EAX,ECX

		AND	EAX,0FH
		JNZ	ZERO_EAX_FINAL_HIGH_WATER

		RET

FINAL_HIGH_PARA ENDP


if	fg_slrpack OR fg_winpack

		PUBLIC	ZERO_EAX_EXEPACK_HIGH_WATER

ZERO_EAX_EXEPACK_HIGH_WATER	PROC
		;
		;WRITE ZEROS OUT TO BUFFERED SEGMENT
		;
		SETT	SPECIAL_ZERO_AXCX
		CALL	ZERO_EAX_EDX_FINAL
		RESS	SPECIAL_ZERO_AXCX
		RET

ZERO_EAX_EXEPACK_HIGH_WATER	ENDP

endif


ZERO_EAX_FINAL_HIGH_WATER	LABEL	PROC

		MOV	EDX,FINAL_HIGH_WATER

ZERO_EAX_EDX_FINAL	PROC
		;
		;WRITE EAX ZEROS TO EDX IN FINAL FILE
		;
		TEST	EAX,EAX
		JZ	L69$

		;
		;NEED EAX ZEROS
		;
		MOV	ECX,MAX_RECORD_LEN

		CMP	EAX,ECX
		JA	L61$

		MOV	ECX,EAX
L61$:
		PUSHM	EDI,EAX

		ADD	ECX,3
		MOV	EDI,OFF TEMP_RECORD

		SHR	ECX,2
		MOV	EAX,ZERO_BYTES

		REP	STOSD

		POP	EAX
L62$:
		;
		;WRITE SMALLER OF BX:AX AND MAX_RECORD_LEN TILL SATISFIED
		;
		MOV	ECX,MAX_RECORD_LEN

		CMP	EAX,ECX
		JNC	L625$

		MOV	ECX,EAX
L625$:
		PUSHM	EDX,ECX

		PUSH	EAX
if	fg_slrpack OR fg_winpack
		GETT	AL,SPECIAL_ZERO_AXCX

		OR	AL,AL
		JNZ	L626$
endif
		MOV	EAX,OFF TEMP_RECORD
		CALL	MOVE_EAX_TO_EDX_FINAL

		POP	EAX
if	fg_slrpack OR fg_winpack
		JMP	L627$

L626$:
		MOV	EAX,OFF TEMP_RECORD
		MOV	EDX,OFF EXEPACK_STRUCTURE

		CALL	STORE_EAXECX_EDX_SEQ

		POP	EAX
L627$:
endif


		POPM	ECX,EDX

		ADD	EDX,ECX
		SUB	EAX,ECX
		JNZ	L62$

		POP	EDI
L69$:
		RET

ZERO_EAX_EDX_FINAL	ENDP


		END

